<?php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
public $recursive = 0;
public $useTable = 'user'; 

public $hasMany = array(
        'Recipe' => array(
            'className'     => 'Recipe',
            'foreignKey'    => 'userId',
           // 'conditions'    => array('Report.solved' => '0'),
            'order'         => 'Recipe.createdTime DESC',
        )
    );

public $validate = array(
        'username' => array(
            'alphaNumeric' => array(
                'rule'     => 'alphaNumeric',
                'required' => true,
                'message'  => 'Alphabets and numbers only'
            ),
            'between' => array(
                'rule'    => array('between', 3, 15),
                'message' => 'Between 3 to 15 characters'
            )
        ),
        'password' => array(
            'rule'    => array('minLength', '4'),
            'message' => 'Minimum 4 characters long',
            'required' => true
        )
    );

public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    }
    return true;
	}

}
?>